@extends('default.layouts.adminPublic')
@section('title', '分类管理列表')

@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/admin/category.css')}}">
    @endsection
    @section('content')

            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/coll_option')}}">首页</a> &raquo; 分类管理
    </div>
    <!--导航结束-->

    <div class="con">
        <div class="manage"></div>
        <div class="conMain">
            <div class="cLeft">
                <div class="cTitle"><a href="{{url('admin/coll_category/')}}"><i class="fa fa-list-ul"></i>分类管理列表</a>
                </div>
                <div class="cateList">
                    <ul>
                        @if(count($collCategory)>0)
                            @foreach($collCategory as $v)
                                <li id="active{{$v->sign}}"><a href="{{url('admin/coll_option/'.$v->sign)}}"><i class="fa fa-fw fa-folder-open"></i>{{msubstr($v->cate_name,0,4)}}</a></li>
                            @endforeach
                        @else
                            <li><a><i class="fa fa-fw fa-ban"></i>列表为空</a></li>
                        @endif
                    </ul>
                </div>

            </div>
            <div class="cRight">
                <div class="list">
                    @if(empty($parameter) || $parameter == 'undefined')
                        <div class="cTitle cTitleList"><i class="fa fa-folder" style="color: #333"></i>请选择分类管理</div>
                    @else
                        <div class="cTitle cTitleList"><a onclick="addOptions(this,'{{$parameter  or '' }}')"><i class="fa fa-plus"></i>添加分类选项</a></div>
                    @endif
                    <div class="listBox">
                        <div class="listCon listScroll">
                            <ul>
                                <li class="optColl">
                                    <div class="options one">
                                        <dl>
                                            <dt class="opt_sort">分类排序</dt>
                                            <dd class="opt_name" style="color: #333">分类名称</dd>
                                            <dd class="opt_name" style="color: #333">英文分类名称</dd>
                                            <dd class="opt_id">分类编码</dd>
                                            <dd class="operating">操作</dd>
                                        </dl>
                                    </div>
                                </li>

                                @if(count($collOptions)>0)
                                    @foreach($collOptions as $v)
                                        <li>
                                            <div class="options optBefore">
                                                <dl>
                                                    <dt class="opt_sort" id="oSort">{{$v['opt_sort']}}</dt>
                                                    <dd class="opt_name" id="oName">{{$v['opt_name']}}</dd>
                                                    <dd class="opt_name" id="oEnName">{{$v['en_opt_name']}}</dd>
                                                    <dd class="opt_id" id="oPid">{{$v['opt_id']}}</dd>
                                                    <dd class="operating">
                                                        <input type="submit" value="编辑"  onclick="editOpt(this,'{{$v['id']}}')" class="sub"  id="editOpt"/>
                                                        <input type="button" value="删除"  onclick="delOptions(this,'{{$v['id']}}','{{$v['sign']}}')" class="sub but" id="delOpt"/>
                                                        <input type="button" value="添加"  onclick="addTwoOptions(this,'{{$v['opt_id']}}','{{$v['sign']}}')" class="sub" id="addOpt"/>
                                                    </dd>
                                                </dl>
                                            </div>

                                            <div class="options optAfter disNone">
                                                <form action="" method="post" name="updateForm" id="updateForm"
                                                      onsubmit="return false">
                                                    {{csrf_field()}}
                                                    <input name="id" value="{{$v['id']}}" type="hidden"/>
                                                    <input name="sign" value="{{$v['sign']}}" type="hidden"/>
                                                    <dl>
                                                        <dt class="opt_sort"><input name="opt_sort" id="opt_sort"  value="{{$v['opt_sort']}}" class="opt sort" type="text"/></dt>
                                                        <dd class="opt_name"><input name="opt_name" id="opt_name" value="{{$v['opt_name']}}" class="opt"  type="text"/></dd>
                                                        <dd class="opt_name"><input name="en_opt_name" id="en_opt_name" value="{{$v['en_opt_name']}}" class="opt"  type="text"/></dd>
                                                        <dd class="opt_id"><input name="opt_id" id="opt_id" value="{{$v['opt_id']}}" class="opt" type="text"/></dd>
                                                        <dd class="operating">
                                                            <input type="submit" value="保存"  onclick="updateOption(this,'{{url('admin/coll_option/'.$v['id'])}}')" class="sub" id="saveOpt"/>
                                                            <input type="button" value="取消" onclick="cancelOption(this)" class="sub but" id="cancelOpt"/>
                                                        </dd>
                                                    </dl>
                                                </form>
                                            </div>
                                        </li>
                                        @if(!empty($parameter))
                                            @foreach($v['CollTwoOption'] as $vv)
                                                <li>
                                                    <div class="options optBefore">
                                                        <dl>
                                                            <dt class="opt_sort" id="oSort">{{$vv['sort']}}</dt>
                                                            <dd class="opt_name" id="oName">{{$v['html']}}{{$vv['name']}}</dd>
                                                            <dd class="opt_name" id="oEnName">@if(!empty($vv['en_name'])){{$v['html']}}{{$vv['en_name']}}@endif</dd>
                                                            <dd class="opt_id" id="oCid">{{$vv['cid']}}</dd>
                                                            <dd class="operating">
                                                                <input type="submit" value="编辑"  onclick="editTwoOpt(this)" class="sub"  id="editOpt"/>
                                                                <input type="button" value="删除"  onclick="delTwoOptions(this,'{{$vv['id']}}')" class="sub but" id="delOpt"/>
                                                            </dd>
                                                        </dl>
                                                    </div>

                                                    <div class="options optAfter disNone">
                                                        <form action="" method="post" name="updateForm" id="updateForm"
                                                              onsubmit="return false">
                                                            {{csrf_field()}}
                                                            <input name="id" value="{{$vv['id']}}" type="hidden"/>
                                                            <input name="pid" value="{{$vv['pid']}}" type="hidden"/>
                                                            <input name="sign" value="{{$vv['sign']}}" type="hidden"/>
                                                            <dl>
                                                                <dt class="opt_sort"><input name="sort" id="sort"  value="{{$vv['sort']}}" class="opt sort" type="text"/></dt>
                                                                <dd class="opt_name"><input name="name" id="name" value="{{$vv['name']}}" class="opt"  type="text"/></dd>
                                                                <dd class="opt_name"><input name="en_name" id="en_name" value="{{$vv['en_name']}}" class="opt"  type="text"/></dd>
                                                                <dd class="opt_id"><input name="cid" id="cid" value="{{$vv['cid']}}" class="opt" type="text"/></dd>
                                                                <dd class="operating">
                                                                    <input type="submit" value="保存"  onclick="updateTwoOption(this,'{{url('admin/coll_two_option/'.$vv['id'])}}')" class="sub" id="saveOpt"/>
                                                                    <input type="button" value="取消" onclick="cancelOption(this)" class="sub but" id="cancelOpt"/>
                                                                </dd>
                                                            </dl>
                                                        </form>
                                                    </div>
                                                </li>
                                            @endforeach
                                        @endif
                                    @endforeach
                                @endif
                            </ul>
                        </div>
                        @if(empty($parameter))
                            <div class="page_list" style="width: 100%; float: left; margin-top:15px;">
                                {!! $collOptionPage->links() !!}
                           </div>
                       @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('footerjs')
    @parent
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.form.js')}}"></script>
    <script type="text/javascript">
        var _token = "{{csrf_token()}}";
        var csrf_field = '{{csrf_field()}}';
        var optUrl = "{{url('admin/coll_option')}}";
        var parameter = '{{$parameter or ''}}';
        if(parameter != '')  $('#active'+parameter).addClass('active');

        var optTwoUrl = "{{url('admin/coll_two_option')}}";
    </script>
    <script type="text/javascript" src="{{asset('/default/js/admin/category.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/admin/two_category.js')}}"></script>
@endsection